package cn.big.bigd.biocode.dao;

import cn.big.bigd.biocode.model.Category;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 *@Author wangfan
 *@Date 2017/12/4 11:36
 */

@Repository
public interface CategoryDAO extends JpaRepository<Category, Long> {

    @Query(value="SELECT * FROM  categories WHERE categories.rgt=categories.lft+1 AND categories.lft >  ?1 AND categories.lft < ?2 ORDER BY lft ASC;",nativeQuery = true)
    List<Category> findLevelsByCategory(int lft ,int rgt);



    List<Category> findByParentId(Integer id);


}
